<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>用户编辑</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

	<link rel="stylesheet" href="${ctxPath}/lib/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="${ctxPath}/css/public.css" media="all">
</head>

<body>
	<div class="layuimini-container">
		<div class="layuimini-main">

			<form class="layui-form" lay-filter="formInfo">
				<input type="hidden" name="id" id="id" class="id layui-input" />

				<div class="layui-row">
					<div class="layui-col-md4">
						<label class="layui-form-label">用户姓名</label>
						<div class="layui-input-block">
							<input type="text" id="realName" name="realName" lay-verType="tips" required
								lay-verify="required" lay-reqtext="用户姓名不能够为空 !" autocomplete="off" placeholder="请输入用户姓名"
								class="layui-input" />
						</div>
					</div>

					<div class="layui-col-md4">
						<label class="layui-form-label">昵称</label>
						<div class="layui-input-block">
							<input type="text" id="nickName" name="nickName" class="layui-input" />
						</div>
					</div>

					<div class="layui-col-md4">
						<label class="layui-form-label">登录账号</label>
						<div class="layui-input-block">
							<input type="text" id="account" name="account" lay-verType="tips" required
								lay-verify="required" lay-reqtext="登录账号不能够为空 !" class="layui-input" />
						</div>
					</div>
				</div>
				<div class="layui-row">
					<div class="layui-col-md4" id="passwordDiv">
						<label class="layui-form-label">登录密码</label>
						<div class="layui-input-block">
							<input type="text" id="password" name="password" lay-verType="tips" required
								lay-verify="required" lay-reqtext="登录密码不能够为空 !" class="layui-input" />
						</div>
					</div>

					<div class="layui-col-md4">
						<label class="layui-form-label">生日</label>
						<div class="layui-input-block">
							<input type="text" id="birthday" name="birthday" class="layui-input" />
						</div>
					</div>

					<div class="layui-col-md4">
						<label class="layui-form-label">性别</label>
						<div class="layui-input-block">
							<select name="userId" id="userId">
								<option value="1">女</option>
								<option value="0">男</option>
							</select>
						</div>
					</div>
				</div>
				<div class="layui-row">
					<div class="layui-col-md4">
						<label class="layui-form-label">邮箱</label>
						<div class="layui-input-block">
							<input type="text" id="email" name="email" class="layui-input" />
						</div>
					</div>

					<div class="layui-col-md4">
						<label class="layui-form-label">手机</label>
						<div class="layui-input-block">
							<input type="text" id="phone" name="phone" class="layui-input" />
						</div>
					</div>

					<div class="layui-col-md4">
						<label class="layui-form-label">Tel</label>
						<div class="layui-input-block">
							<input type="text" id="tel" name="tel" class="layui-input" />
						</div>
					</div>
				</div>
				<div class="layui-row">
					<div class="layui-col-md6">
						<label class="layui-form-label">是不是超管</label>
						<div class="layui-input-block">
							<select name="superAdminFlag" id="superAdminFlag">
								<option value="0">不是</option>
								<option value="1">是</option>
							</select>
						</div>
					</div>

					<div class="layui-col-md6">
						<label class="layui-form-label">排序</label>
						<div class="layui-input-block">
							<input type="text" id="sort" name="sort" value="100" lay-verify="number" class="layui-input" />
						</div>
					</div>
				</div>
				<div class="layui-row">
					<div class="layui-col-md12">
						<label class="layui-form-label">描述</label>
						<div class="layui-input-block">
							<textarea placeholder="请输入内容" id="remark" name="remark" class="layui-textarea"></textarea>
						</div>
					</div>
				</div>
				
				<div class="layui-row">
					<div class="layui-col-md6">
						<div class="layui-input-block">
							<button class="layui-btn" lay-submit="" lay-filter="btn-form-submit">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</div>
			</form>

		</div>
	</div>

	<script src="${ctxPath}/lib/layui/layui.js" charset="utf-8"></script>
	<script src="${ctxPath}/js/core.util.js" charset="utf-8"></script>
	<script src="${ctxPath}/js/lay-config.js?v=2.0.0" charset="utf-8"></script>

	<script type="text/javascript">
		layui.use(['form', 'layer', 'notice'], function () {
			var $ = layui.jquery, form = layui.form, layer = layui.layer, notice = layui.notice;

			// 获取详情信息，填充表单
			let id = request("id");
			if (id != "") {
				sendAjax("/sys/user/findById?id=" + id, null, function (result) {
					form.val('formInfo', result.data);
					$("#passwordDiv").remove();
				}, "GET");
			}

			/*
			sendAjax("/sys/user/listAll", null, function (rest) {
				console.log(rest);
				$("#pid").empty().append("<option value=''>请选择父节点</option>");
				$.each(rest.data, function (i, e) {
					$("#pid").append("<option value='" + e.id + "'>" + e.groupName + "</option>");
				});
				form.render('select');
			});
			*/

			//监听提交
			form.on('submit(btn-form-submit)', function (data) {

				sendAjax("/sys/user/saveOrUpdate", JSON.stringify(data.field), function (rest) {
					notice.msg(rest.msg, {icon: 1});
				}, "POST");

				return false;
			});

		});
	</script>
</body>

</html>